package cn.com.qingz.modules.user.mapper;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;

import cn.com.qingz.modules.user.model.Customer;
import cn.com.qingz.modules.user.model.Design;
import cn.com.qingz.modules.user.vo.CustomerSearchCondition;
import tk.mybatis.mapper.common.Mapper;

public interface CustomerMapper extends Mapper<Customer> {

    public PageList<Customer> queryForPage(CustomerSearchCondition condtion, PageBounds pageBounds);

    //这样好像会 其他登录覆盖这个 
    @Select("select count(1) from customer where token = #{token} ")
    public Integer findEnableToken(@Param("token") String token);
    
    @Select("select count(1) from customer where phone = #{phone}")
    public Integer countCustomerByPhone(@Param("phone") String phone);

    @Select("select *  from customer where phone = #{phone} AND password = #{password}")
    public Customer login(@Param("phone") String phone, @Param("password") String password);

    @Insert("insert into  customer (password,realname,email,phone,create_date,profile,orgname,usertype)"
            + " values (#{password} , #{realname},#{email},#{phone},#{create_date},#{profile},#{orgname},#{usertype}) ")
    public void save(Customer customer);

    @Select("select * from design where userid = #{userid}")
    public List<Map<String, Object>> getUserDesign(@Param("userid") Integer userid);

    @Select("select * from design m where m.title like '%${keyword}%'   ")
    public PageList<Design> queryHouseModelByPage(@Param("keyword") String keyword, PageBounds pd);

}
